<?php

class SecurityAction extends Action{
	
	var $permission = '';
	
	function __construct(){
		parent::__construct();
		
// 		$tmp = unserialize(session('info.permission'));
// 		$su = (session('info.su'));
// 		foreach($tmp as $key=>$value){
// 			$this->permission[$value] = '1';
// 		}
		
		if(empty(session('info'))){
// 			exit('请先登录');
            $this->error('请先登录','/console/login');
            exit();
            return ;
		}
		
		$ob = M("yq_role");
		$per = $ob->where(array('rid'=>session('info.rid')))->find();
		
// 		$ob = M("t_admin_permission");
// 		$list = $ob->select();
// 		if($su == '1'){
// 			foreach($list as $key=>$value){
// 				$this->permission[$value['code']] = '1';
// 			}
// 		}
// 		$this->assign('permission',$this->permission);
	}
	
	public function checkPermission($code){
		
		if($this->permission[$code] != 1){
			exit('权限请求错误，请联系管理员');
		}
	}
	
}